
package planete;


public class Vektor
{
	private double	x, y, z;
	
	public Vektor()
	{
		this(0, 0, 0);
	}
	
	public Vektor(double x, double y, double z)
	{
		this.x = x; this.y = y; this.z = z;
	}
	
	public Vektor zbir(Vektor v)
	{
		return new Vektor(x + v.x, y + v.y, z + v.z);
	}
	
	public Vektor dodaj(Vektor v)
	{
		x += v.x; y += v.y; z += v.z;
		return this;
	}
	
	public Vektor proizvod(double f)
	{
		return new Vektor(x * f, y * f, z * f);
	}
	
	public Vektor mnozi(double f)
	{
		x *= f; y *= f; z *= f;
		return this;
	}
	
	public double x() { return x; }
	public double y() { return y; }
	public double z() { return z; }
	
	public double razdaljina(Vektor v)
	{
		return Math.sqrt( razdaljina2(v) );
	}

	public double razdaljina2(Vektor v)
	{
		return Math.pow(x-v.x, 2) + Math.pow(y-v.y, 2) + Math.pow(z-v.z, 2);
	}
	
	public void setX(double xa) { x=xa; }
	public void setY(double ya) { y=ya; }
}